Using UIAlertView to create following alert, which is showing extra spaces in top & bottom As seen in Image 1.
I want to remove this spacings as seen in Image 2.
Please suggest any solution.
My code for alert : Using iOS 7.1
- (id)initWithFrame:(CGRect)frame Cancel:(NSString *)CancelValue Set:(NSString *)SetValue Tag:(int)TagValue Array:(NSMutableArray *)ArrayValue
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
UIView *vwAlert = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 380)];
[alert addSubview:vwAlert];
UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(20, 0, 280, 350) style:UITableViewStylePlain];
table.dataSource = self;
table.delegate = self;
table.scrollEnabled = NO;
table.tag = TagValue;
[table setSeparatorInset:UIEdgeInsetsZero];
[vwAlert addSubview:table];
aryTitle = [[NSMutableArray alloc] initWithObjects:@"Sort Habits",@"Habit Records",@"Category", nil];
vwAlert.frame = CGRectMake(0, 0, 320, 170);
table.frame = CGRectMake(20, 0, 280, vwAlert.frame.size.height);
btnCancel.hidden=YES;
btnSet.hidden=YES;
UIImageView *imgVw = [[UIImageView alloc] initWithFrame:CGRectMake(250, 2, 40, 40)];
imgVw.image = [UIImage imageNamed:@"icon_filter_clear"];
[vwAlert addSubview:imgVw];
UIButton *btnClearAll = [UIButton buttonWithType:UIButtonTypeSystem];
btnClearAll.frame = CGRectMake(235, 0, 60, 40);
[btnClearAll addTarget:self action:@selector(funClearAll:) forControlEvents:UIControlEventTouchUpInside];
[vwAlert addSubview:btnClearAll];
[table reloadData];
[alert setValue:vwAlert forKey:@"accessoryView"];
[alert show];
}
return self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
cell.textLabel.text = [aryRestore objectAtIndex:(indexPath.row)];
cell.textLabel.font = [UIFont fontWithName:@"Avenir Next" size:16];
return cell;
}
Image 1
Image 2
Aucun commentaire:
Enregistrer un commentaire