如何使用目标c

时间:2015-10-09 19:33:30

标签: ios objective-c ios8-today-widget

嘿伙计我正在开发一个iOS应用程序,它有一个今天的小部件,当用户点击相机按钮时,它将打开我在我的应用程序中通过故事板制作的相机应用程序我已经完成研究并发现你可以使用URL方案,但我只在swift中找到了示例,我的应用程序在Objective-C中完成。

以下是小部件的代码:

#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>


@interface TodayViewController () <NCWidgetProviding>

@end

@implementation TodayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

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

-(IBAction)internetbttn: (id)sender {
    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    [self.extensionContext openURL:url completionHandler:nil];
}

-(IBAction)emailbttn: (id)sender {
    NSURL *url = [NSURL URLWithString:@"mailto:"];
    [self.extensionContext openURL:url completionHandler:nil];
}


-(IBAction)itunesstorebttn: (id)sender {
    NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/genre/music/id36?mt=8"];
    [self.extensionContext openURL:url completionHandler:nil];
}


-(IBAction)appstorebttn: (id)sender {
    NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/genre/mobile-software-applications/id36?mt=8"];
    [self.extensionContext openURL:url completionHandler:nil];
}



-(IBAction)musicbttn: (id)sender {
    NSURL *url = [NSURL URLWithString:@"music://"];
    [self.extensionContext openURL:url completionHandler:nil];
}

-(IBAction)photobttn:(id)sender {

    //This is where the photo button needs to go!

}





- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
    // Perform any setup necessary in order to update the view.

    // If an error is encountered, use NCUpdateResultFailed
    // If there's no update required, use NCUpdateResultNoData
    // If there's an update, use NCUpdateResultNewData

    completionHandler(NCUpdateResultNewData);
}


@end

有关如何在Objective-C中执行此操作的任何想法

提前致谢

0 个答案:

没有答案