开发者

Change the title of the edit button iPhone

I have a tableview with an edit button on the left.

I created this edit button using

self.navigationItem.leftBarButtonItem = self.editButtonItem;

I want to know how to change the title of t开发者_JAVA技巧he Edit button to 'delete'

Cheers


Changing the visual title of the edit button to 'Delete' is a bad idea -- you'll probably find your app gets rejected for doing something as ill advised as that. If it does get into the store, you'll confuse your users. Don't do it!

If you want a button called Delete that does something specific directly related to deleting that has a clear context, that's another matter. Note that destructive action buttons are usually a red colour, to signal to the user that there's a destructive action there, and sometimes pop up a UIActionSheet to confirm the user's destructive action.

Please read Apple' Human Interface Guidelines:

http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/Introduction/Introduction.html


You can just change button title. Here is the code

self.editButtonItem.title = @"Delete";
self.navigationItem.leftBarButtonItem = self.editButtonItem;


Doable, though it might not be a good idea. See this answer by occulus.

Create a UIBarButtonItem as usual:

self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Whatever" style: UIBarButtonItemStyleBordered target:self action:@selector(doSomething)] autorelease];

Then call [self setEditing:!self.editing] in -(void)doSomething.


Try

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"your title" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜