Iphone 如何自定义TTMessageController字段?
我使用获取一个收件人选择器和一个用于编写sms消息的文本区域。然而,我仍然不需要这个“主题”字段 如何删除它 我就是这样创建的:Iphone 如何自定义TTMessageController字段?,iphone,xcode,three20,Iphone,Xcode,Three20,我使用获取一个收件人选择器和一个用于编写sms消息的文本区域。然而,我仍然不需要这个“主题”字段 如何删除它 我就是这样创建的: SecondViewController是的子类。那么,如何对其进行自定义以删除/添加字段,尤其是主题字段?创建TTMessageController的子类并重写initWithNibName。在overidden initWithNibName方法中,设置_fields数组以仅保留您想要的字段。下面的示例将仅保留To:字段 /////////////////////
SecondViewController是的子类。那么,如何对其进行自定义以删除/添加字段,尤其是主题字段?创建TTMessageController的子类并重写initWithNibName。在overidden initWithNibName方法中,设置_fields数组以仅保留您想要的字段。下面的示例将仅保留To:字段
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
self.dataSource = [[AddressBookDataSource new] autorelease];
_fields = [[NSArray alloc] initWithObjects:
[[[TTMessageRecipientField alloc] initWithTitle: TTLocalizedString(@"To:", @"")
required: YES] autorelease], nil];
self.showsRecipientPicker = YES;
self.title = TTLocalizedString(@"New Message", @"");
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle: TTLocalizedString(@"Cancel", @"")
style: UIBarButtonItemStyleBordered
target: self
action: @selector(cancel)] autorelease];
}
return self;
}
创建TTMessageController的子类并重写initWithNibName。在overidden initWithNibName方法中,设置_fields数组以仅保留您想要的字段。下面的示例将仅保留To:字段
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
self.dataSource = [[AddressBookDataSource new] autorelease];
_fields = [[NSArray alloc] initWithObjects:
[[[TTMessageRecipientField alloc] initWithTitle: TTLocalizedString(@"To:", @"")
required: YES] autorelease], nil];
self.showsRecipientPicker = YES;
self.title = TTLocalizedString(@"New Message", @"");
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle: TTLocalizedString(@"Cancel", @"")
style: UIBarButtonItemStyleBordered
target: self
action: @selector(cancel)] autorelease];
}
return self;
}
什么是SMSMessageRecipientField?我必须创建它吗?对不起,这是我项目中TTMessageRecipientField的一个子类。您可以替换为TTMessageRecipientField。什么是SMSMessageRecipientField?我必须创建它吗?对不起,这是我项目中TTMessageRecipientField的一个子类。您可以替换为TTMessageRecipientField。