按下按钮时不调用IBAction方法。但正在推动View控制器

时间:2014-04-20 07:38:22

标签: objective-c xcode null push ibaction

我正尝试使用名为viewController的{​​{1}}按钮推送segue,将信息从一个IBAction传递到另一个*line。但是据我所知,这个方法没有被调用和NSLog(@“%@”,见);我插入测试方法没有显示任何消息。以下是第一个viewController的代码。

DetailController.m

#import "DetailController.h"
#import "City.h"
#import "ViewController.h"

#import "VideoController.h"
#import "Helper.h"

@interface DetailController ()

@property (nonatomic, strong) IBOutlet VideoController *videoViewController;
@end

@implementation DetailController
@synthesize city, ClubName, Price, Vip, Promo, remain,p,deal,money,camera,tweet,post;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{
self.videoViewController = [[VideoController alloc] init];
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320,1400)];
[super viewDidLoad];
UIImage *highlightedButtonImage = [UIImage imageNamed:@"twitter.png"];
 UIImage *highlightedButtonImage2 = [UIImage imageNamed:@"twitter2.png"];

[Helper customizeBarButton:self.tweet image:highlightedButtonImage highlightedImage:highlightedButtonImage2];

UIImage *faceButtonImage = [UIImage imageNamed:@"facebook.png"];
UIImage *faceButtonImage2 = [UIImage imageNamed:@"facebook2.png"];

[Helper customizeBarButton:self.post image:faceButtonImage highlightedImage:faceButtonImage2];

UIImage *taxiButtonImage = [UIImage imageNamed:@"taxi.png"];
 UIImage *taxiButtonImage2 = [UIImage imageNamed:@"taxi2.png"];

[Helper customizeBarButton:self.taxi image:taxiButtonImage highlightedImage:taxiButtonImage2];

// Do any additional setup after loading the view.
UIFont *labelFont=[UIFont fontWithName:@"King Kikapu" size:15.0];
UIFont *myFont=[UIFont fontWithName:@"Deutsch Gothic" size:20.0];
UIFont *myFont2=[UIFont fontWithName:@"Deutsch Gothic" size:35.0];
UIFont *titleFont=[UIFont fontWithName:@"Pornstar" size:50.0];
NSString * name= self.city.clubName;
NSString * line= self.city.clubLine;
NSString * description= self.city.promo;
NSString * price= self.city.price;
NSString *ipCam= self.city.camera;

remain.font=labelFont;
remain.text=@"VIP Remaining :";
p.font=labelFont;
p.text=@"Price :";
money.font=myFont;

deal.font=labelFont;
deal.text=@"Promotions :";

ClubName.font=titleFont;
ClubName.text=name;
Vip.font=myFont2;
Vip.text=line;
Price.font=myFont2;
Price.text=price;
Promo.font=myFont;
Promo.text=description;



}
- (IBAction)PostFacebook:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    SLComposeViewController * facebook= [[SLComposeViewController alloc]init];

    facebook= [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [facebook setInitialText:[NSString stringWithFormat:@"I'm heading to"]];
    [self presentViewController:facebook animated:YES completion:nil];

    [facebook setCompletionHandler:^(SLComposeViewControllerResult result){
        NSString * output;
        switch (result) {
            case SLComposeViewControllerResultCancelled:
                output=@"Action Cancelled";
                break;
            case SLComposeViewControllerResultDone:
                output=@"Post Succesful";
            default:
                break;
        }
        UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
        [alert show];
    }];
}}

- (IBAction)PostTwitter:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
    SLComposeViewController *tweetSheet= [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:@"I'm heading to"];
    [self presentViewController: tweetSheet animated:YES completion:nil];
}
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (IBAction)line:(id)sender {
NSString *see=self.city.camera;
NSLog(@"%@", see);

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                                     bundle:nil];
self.videoViewController = [storyboard instantiateViewControllerWithIdentifier:@"Page3"];
self.videoViewController.city.camera= self.city.camera;

[self.navigationController pushViewController:self.videoViewController animated:YES];
}

@end

作为测试,我将NSLog(@"%@", see);插入IBAction方法,但这不会返回任何值

DetailController.h

#import <UIKit/UIKit.h>
#import "VideoController.h"
#import <Social/Social.h>

@class City;

@interface DetailController : UIViewController {
    IBOutlet UIScrollView *scroller;
}

@property (weak, nonatomic) IBOutlet UIBarButtonItem *taxi;

@property (strong,nonatomic) City *city;
@property (weak, nonatomic) IBOutlet UILabel *ClubName;
@property (weak, nonatomic) IBOutlet UILabel *Vip;
@property (weak, nonatomic) IBOutlet UILabel *Price;

@property (nonatomic, strong)NSString * camera;
@property (weak, nonatomic) IBOutlet UILabel *Promo;
@property (weak, nonatomic) IBOutlet UILabel *remain;
@property (weak, nonatomic) IBOutlet UILabel *p;
@property (weak, nonatomic) IBOutlet UILabel *deal;
@property (weak, nonatomic) IBOutlet UILabel *money;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *tweet;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *post;

- (IBAction)line:(id)sender;

@end

感谢您提供有关在按下按钮时未调用此方法的任何建议

1 个答案:

答案 0 :(得分:1)

当您没有正确连接按钮时,您的IBAction不被调用的唯一方法。在连接检查器中仔细检查。

相关问题