草庐IT

nsnotificationcenter

全部标签

iphone - NSNotificationCenter 与委派(使用协议(protocol))?

它们各自的优缺点是什么?我应该具体在哪里使用它们? 最佳答案 这里的经验法则是有多少客户希望收到事件通知。如果它主要是一个对象(例如,关闭View或对单击的按钮进行操作,或对下载失败使用react),那么您应该使用委托(delegate)模型。如果您发出的事件可能同时对许多对象感兴趣(例如屏幕旋转、内存使用、用户登录/注销),那么您应该使用NSNotificationCenter。 关于iphone-NSNotificationCenter与委派(使用协议(protocol))?,我们在

iphone - NSNotificationCenter 与委派(使用协议(protocol))?

它们各自的优缺点是什么?我应该具体在哪里使用它们? 最佳答案 这里的经验法则是有多少客户希望收到事件通知。如果它主要是一个对象(例如,关闭View或对单击的按钮进行操作,或对下载失败使用react),那么您应该使用委托(delegate)模型。如果您发出的事件可能同时对许多对象感兴趣(例如屏幕旋转、内存使用、用户登录/注销),那么您应该使用NSNotificationCenter。 关于iphone-NSNotificationCenter与委派(使用协议(protocol))?,我们在

objective-c - 当键盘出现在 iOS 中时,将 UIView 上移

我有一个UIView,它不在UIScrollView里面。当键盘出现时,我想上移我的View。在我尝试使用此解决方案之前:HowcanImakeaUITextFieldmoveupwhenthekeyboardispresent?.工作正常。但是在文本字段中插入数据后,它会将我带到另一个View,当我回到这个页面时,它只是在跳跃,我看不到我的文本字段。有没有更好的办法解决这个问题? 最佳答案 -(void)viewWillAppear:(BOOL)animated{[superviewWillAppear:animated];[[N

objective-c - 当键盘出现在 iOS 中时,将 UIView 上移

我有一个UIView,它不在UIScrollView里面。当键盘出现时,我想上移我的View。在我尝试使用此解决方案之前:HowcanImakeaUITextFieldmoveupwhenthekeyboardispresent?.工作正常。但是在文本字段中插入数据后,它会将我带到另一个View,当我回到这个页面时,它只是在跳跃,我看不到我的文本字段。有没有更好的办法解决这个问题? 最佳答案 -(void)viewWillAppear:(BOOL)animated{[superviewWillAppear:animated];[[N

ios - 在 Objective-C 中通过 NSNotificationCenter 发送和接收消息?

我正在尝试通过Objective-C中的NSNotificationCenter发送和接收消息。但是,我无法找到任何有关如何执行此操作的示例。如何通过NSNotificationCenter发送和接收消息? 最佳答案 @implementationTestClass-(void)dealloc{//Ifyoudon'tremoveyourselfasanobserver,theNotificationCenter//willcontinuetotryandsendnotificationobjectstothedeallocated

ios - 在 Objective-C 中通过 NSNotificationCenter 发送和接收消息?

我正在尝试通过Objective-C中的NSNotificationCenter发送和接收消息。但是,我无法找到任何有关如何执行此操作的示例。如何通过NSNotificationCenter发送和接收消息? 最佳答案 @implementationTestClass-(void)dealloc{//Ifyoudon'tremoveyourselfasanobserver,theNotificationCenter//willcontinuetotryandsendnotificationobjectstothedeallocated