정보창을 누르면 작성된 modalViewController보기를 표시하기 위해 주 창에 있습니다. 하지만 주 창에서 정보 버튼을 누르면 아무 일도 일어나지 않습니다. 내가 다음 코드 한 mainviewcontroller.h 파일에서 프로그래밍 방식으로 UIToolbar에서 눌렀을 때 정보 단추 용 Modalviewcontroller 표시
: 다음 코드 한#import "imageviewViewController.h"
#import "Infoviewcontroller.h"
@implementation imageviewViewController
@synthesize toolbar;
@synthesize currentSystemItem;
@synthesize audioPlayer;
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc]
initWithTitle:@"Info"
style:UIBarButtonItemStyleBordered
target:nil
action:@selector(Infobuttonpressed)];
// flex item used to put space in between buttons
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
//Add buttons to the array
NSArray *toolbarItems = [NSArray arrayWithObjects: settingsButton, flexItem, systemItem, flexItem, systemItem1,flexItem, systemItem2, flexItem, systemItem3, flexItem, infoItem, nil];
[toolbar setItems:toolbarItems];
[settingsButton release];
[systemItem release];
[systemItem1 release];
[systemItem2 release];
[systemItem3 release];
[infoItem release];
[flexItem release];
[super viewDidLoad];
}
- (void) Infobuttonpressed: (id) sender
{
Infoviewcontroller *myView = [[Infoviewcontroller alloc] init];
[self presentModalViewController:myView animated:YES]; // present view modally
[self.navigationController pushViewController:myView animated:YES]; // add to navigation stack
[myView release];
}
Infoviewcontroller.h 파일에서 : 다음 mainviewcontroller.m 파일에서
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface imageviewViewController : UIViewController{
AVAudioPlayer *audioPlayer;
}
@property (nonatomic, retain) UIToolbar *toolbar;
@property (nonatomic, assign) UIBarButtonSystemItem currentSystemItem;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
@end
코드를 다음 한
을#import <UIKit/UIKit.h>
@interface Infoviewcontroller : UIViewController <UITextViewDelegate>
{
UITextView *textView;
}
@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;
@end
다음 infoviewcontroller.m 파일에는 다음 코드가 있습니다.
#import "Infoviewcontroller.h"
@implementation Infoviewcontroller
@synthesize textView;
@synthesize navBar;
-(void)dealloc
{
[textView release];
[navBar release];
[super dealloc];
}
-(void)setupTextView
{
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
self.textView.textColor = [UIColor redColor];
self.textView.font = [UIFont fontWithName:@"System Bold" size:13];
self.textView.delegate = self;
self.textView.backgroundColor = [UIColor whiteColor];
self.textView.textAlignment = UITextAlignmentCenter;
self.textView.text = @"This is UITextView\nThis is UITextView\nThis is UITextView\nThis is UITextView";
[self.view addSubview: self.textView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
navBar = [[UINavigationBar alloc] init];
UINavigationItem *navItem = [[[UINavigationItem alloc] initWithTitle:@"ModalViewControllerTest"] autorelease];
UIBarButtonItem *done = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease];
navItem.rightBarButtonItem = done;
navBar.items = [NSArray arrayWithObject:navItem];
[self.view addSubview:navBar];
}
info view 컨트롤러에 nib 파일이 있습니까? 아니면 코드로 모두 빌드하고 있습니까? – jrturton
프로그래밍 방식으로 수행하고 있습니다 – user1120133
그리고 중단 점을 사용하여 얼마나 멀리 있는지 확인 했습니까? 액션 메소드가 실행 되었습니까? 컨트롤러의 어떤 메소드가 실행됩니까? – jrturton