我在通知回来之后尝试更改按钮的标题,但它根本没有响应.我检查了它不是零并检查我分配的文本,一切都很好.我做了属性类型strong而不是weak成功.
- (void) setButtonTitleFromSelectedSearchResult:(NSNotification *)notif
{
[self popController];
self.sourceMapItem = [[notif userInfo] valueForKey:@"SelectedResult"];
NSLog(@"The Selected Result is: %@", self.sourceMapItem.name);
//Testing
NSLog(@"%@", self.fromButton); // check it's not nil
[self.fromButton setTitle:self.sourceMapItem.name];
}
Run Code Online (Sandbox Code Playgroud) 2015-05-02 23:56:34.047 TapIt WatchKit Extension[1398:18615] b: <WKInterfaceButton: 0x6080000580c0>
2015-05-02 23:56:34.048 TapIt WatchKit Extension[1398:18615] sender: (null)
- (IBAction)tapped:(id)sender {
bool success = false;
NSLog(@"b: %@", b);
NSLog(@"sender: %@", sender);
Run Code Online (Sandbox Code Playgroud)
为什么这会通过零?