Tôi gặp sự cố khi tôi muốn gọi hàm được xác định trong một bộ điều khiển chế độ xem từ bộ điều khiển khác. Tôi sẽ thử những gì có vẻ llke một trăm thiết lập khác nhau và không có gì dường như làm việc.Gọi hàm từ bộ điều khiển chế độ xem khác cho iphone
Tôi đã đăng mã cơ bản và hy vọng một người nào đó có thể cho tôi biết họ sẽ làm như thế nào. Về cơ bản tất cả những gì tôi muốn làm là gọi hàm MYBPress được định nghĩa trong SwitchViewController từ GameViewController khi nút dealB được nhấn. Mọi sự trợ giúp sẽ rất được trân trọng. PS: Tôi đã được mã hóa trong một thời gian dài, nhưng tôi realtivly mới để obj-C
// ------- SwitchViewController.h ---------------
#import <UIKit/UIKit.h>
@class GameViewController;
@class OptionsViewController;
@interface SwitchViewController : UIViewController {
OptionsViewController *optionsViewController;
}
@property (retain, nonatomic) OptionsViewController *optionsViewController;
@property (retain, nonatomic) GameViewController *gameViewController;
-(IBAction)MyBPress:(id)sender;
@end
// -------- GameViewController.h ------------
#import <UIKit/UIKit.h>
@interface GameViewController : UIViewController {
IBOutlet UIButton *dealB;
}
@property(nonatomic,retain) IBOutlet UIButton *dealB;
- (IBAction)dealB:(id)sender;
@end
// ------- GameViewController.m
#import "GameViewController.h"
@implementation GameViewController
@synthesize dealB; // The Deal button
- (IBAction)dealB:(id)sender
{
// Here is where I want to call the MyBPress function
}
@end
Cảm ơn bạn đã nhập. Nó là một thiết kế tồi? Có lẽ, nhưng câu hỏi là, nó có thể được thực hiện. –
Xin chào, St3fan, tôi đã quay lại và thử lại bằng NsNotificationCenter và làm cho nó hoạt động. Tôi đã thử nó trước đó nhưng rõ ràng là không làm đúng. Sự thất vọng của tôi đã khiến tôi thử các phương pháp độc đáo :-) Nhận xét của bạn khiến tôi nhìn lại nó và tôi đã tìm ra nó, vì vậy cảm ơn cho đầu vào. –