ios - 未调用 tableview 页脚中的按钮
<p><p>我已经在 <code>UIView</code></p> 中声明了 <code>UIView</code> 和 <code>UIButton</code>
<pre><code>-(void)viewWillAppear:(BOOL)animated
{
footerView = [ initWithFrame:CGRectMake(0,0,320,300)];
UILabel *totallabel = [initWithFrame:CGRectMake(50,5,320,40)];
totallabel.text = @"Grand Total =";
totallabel.font = ;
totallabel.font = ;
;
UILabel *lblRs = [initWithFrame:CGRectMake(160,5,320,40)];
lblRs.text = @"Rs.";
lblRs.font = ;
lblRs.font = ;
;
totalcostlabel = [initWithFrame:CGRectMake(190,5,320,40)];
totalcostlabel.font = ;
totalcostlabel.font = ;
;
UIButton *aButton = ;
aButton.frame =CGRectMake(70,50,150,40);
aButton.backgroundColor = ;
;
forState:UIControlStateNormal];
aButton.titleLabel.font = ;
;
;
;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return footerView;
}
- (void)btnChackOut:(UIButton *)sender {
NSLog(@"btn clicked");
}
</code></pre>
<p>当我点击在我的页脚中声明的 Checkout 按钮时,不会执行点击事件并且不会调用操作方法</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我得到了解决方案,现在它已经奏效了。应用下面的代码。</p>
<p>在.h中</p>
<pre><code> #import "CustomCell.h"
-(IBAction)actionContinue:(id)sender;
@property (strong, nonatomic) IBOutlet UITableView *tblViewCart;
</code></pre>
<p>在.m</p>
<pre><code>@synthesize tblViewCart;
- (void)viewDidLoad
{
;
// Do any additional setup after loading the view from its nib.
arrayImageCart = [initWithObjects:@"ios7.jpg",@"iphone_6.jpg",nil];
arrayPrice = [initWithObjects:@"Rs 60,000",@"Rs 55,000",nil];
arrayDescription = [initWithObjects:@"Made In China",@"Headquarter is in US",nil];
arrayOtherDetail = [initWithObjects:@"Black Color",@"White Color",nil];
arraySubTotal = [initWithObjects:@"Rs 60,000",@"Rs 55,000",nil];
arrayTotal = [initWithObjects:@"110000",nil];
arrayTotalCharges = [initWithObjects:@"2000",nil];
arrayYouPay = [initWithObjects:@"112000", nil];
self.tblViewCart.separatorColor = ;
}
// Button Action
-(IBAction)actionContinue:(id)sender
{
}
#pragma mark - UITableView Delegate Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 203;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section==0)
return arrayPrice.count;
else
return arrayYouPay.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *);
NSArray *nib = [loadNibNamed:@"CustomCell" owner:self options:nil];
if(indexPath.section==0)
{
cell = ;
cell.imageViewCart.image = ]];
cell.lblPriceDetails.text = ];
cell.lblDescriptionAbtProduct.text = ];
cell.labelOtherDetails.text = ];
cell.lblSubTotal.text = ];
}
else
{
cell = ;
cell.lblTotal.text = ];
cell.lblTotalCharges.text = ];
cell.lblYouPay.text = ];
}
return cell;
}
</code></pre>
<p>通过 NewFile->Source->CocoaTouchClass->Next>SubClassof:UITableViewCell,Class->CustomClass 和 CheckBox 创建自定义单元 也创建 XIB 文件(这是价格详情)。
然后在 CustomCell.xib 文件中创建另一个 UITableViewCell 并为 Total Amount 和 Pay 命名为 CustomCell。</p></p>
<p style="font-size: 20px;">关于ios - 未调用 tableview 页脚中的按钮,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/31578895/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/31578895/
</a>
</p>
页:
[1]