开发者

Uitableview within uiview

I have Uitable view within uiview with navigati开发者_如何学JAVAon bar , I want to add button to the navigation bar to edit the contents of uitableview

any suggestion how to do that please


I think that you want to place your UITableView controller within a UINavigationController (see the UINavigationController class reference for more information).

In your UIViewController for the UITableView, you need to override the methods found under the "Configuring a Navigation Interface" section of the Apple Developer Documentation.

Within this section of methods lies - (UIBarButtonItem *)editButtonItem, which you could override to provide the button for your editing purpose. Under the hood, the UINavigationController will call this method to get the edit button for its user interface. Using this technique ensures that your app stays consistant with the user expierence iOS users have come to love.


There is solution that I tried and worked for me. The solution is

in .h file

UIBarButtonItem *edit;

and set property line as

@property (nonatomic , retain) IBOutlet UIbarButtonItem *edit;

in .m file

in your action handler of the button add

[self.tableView setEditing:TRUE];

Open the .xib file of your view controller and add a UIBarButtonItem either to left or right side of the Navigation Bar and connect the respective IBOutlet to edit button and also the selector method.

Now in the delgate of tableView add the following method

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
//sets the editing style for every row.
return UITableViewCellEditingStyleDelete;
}

Now you can play around with the UITableViewDelegate Methods and also the above methos to get the desired functionality.

Hope it works and do communicate if it does!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜