作者:Loving_iOS
转载请标明出处:http://blog.csdn.net/loving_ios/article/details/50678207
在使用UIAlertView的时候,初始化时使用方法
- (instancetype)initWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles,
, ...会给一个title和message。有时大家不需要title就会直接给message而title给空字符串或者nil.两者会有什么区别哪。如果给空字符串如:
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@""
message:@"你好"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"确认",nil];
会得到如下提示框
如果给nil会得到如下提示框
大家应该看出两者信息的字体区别了,如果title给空字符串,标题是存在的,信息会在title下面小于标题字号显示,如果给nil标题不存在,信息会在标题位置显示,并且以标题字号显示。这是两者的区别,大家在开发时可以注意这个问题。