Tag: 目标C

当应用程序启动时,Qt for iOSlocking正面。 (qiosscreen.mm断言)

我将Qt for iOS项目迁移到Qt 5.5。 至less在iOS 5.1.1中,如果您在设备面朝上启动应用程序,则应用程序无法启动。 一个断言在第344行的qiosscreen.mm中显示错误。下面是Qt源代码失败的函数: Qt::ScreenOrientation QIOSScreen::orientation() const { // Auxiliary screens are always the same orientation as their primary orientation if (m_uiScreen != [UIScreen mainScreen]) return Qt::PrimaryOrientation; UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; // At startup, iOS will report an unknown orientation for the device, even // if we've asked it to begin […]

date格式化问题在ObjC中

我需要将datestring“2015-03-10 00:00:00.000”(来自Web服务的string)转换为NSDate。 我已经使用这样的代码 NSDateFormatter *fromDateFormat = [[NSDateFormatter alloc] init]; [fromDateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *outputDate = [fromDateFormat dateFromString:@"2015-03-10 00:00:00.000"]; outputDate是零。 我尝试没有最后三个零,它正在工作。 但是我不能删除那个零,因为它来自一个服务。

如何使用委托从一个视图控制器传递消息到另一个使用委托?

主要故事板图像我有一个名为“Contacttableviewcontroller”的表视图控制器和一个视图控制器为“Detailviewcontroller”。 我有2个文本字段在我的视图控制器给联系人姓名和号码。 我有一个button来保存。 当我点击那个button时,它应该显示在Table View Controller中。 我正在使用的概念是使用委托从目的地到源代码传递信息。 这里是我的代码不正常工作。 Detailviewcontroller.h @protocol detailviewcontrollerdelegate<NSObject> – (void)additem:(NSString *)Name MOBILE:(NSString *)Mobile; @end @interface DetaiViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *nametextfield; @property (weak, nonatomic) IBOutlet UITextField *mobiletextfield; – (IBAction)Save:(id)sender; @property(nonatomic,weak)id<detailviewcontrollerdelegate>delegate; Detailviewcontroller.m – (IBAction)Save:(id)sender { [self.delegate additem:self.nametextfield.text MOBILE:self.mobiletextfield.text]; } Contacttableviewcontroller.h @interface ContactTableViewController : UITableViewController<detailviewcontrollerdelegate> @property(strong,nonatomic)NSString *contactname; @property(strong,nonatomic)NSString *contactno; -(void)reloadtabledata; @property(strong,nonatomic)NSArray […]

iAd框架在iPhone上返回错误的高度

我有一个iAd,我试图把它放在屏幕的底部,虽然当我试图获得广告的高度,以便我可以把它放在底部。 这个错误只发生在横向进入屏幕时,因为广告在纵向方向上更高,只在iPhone模拟器上,因为在iPad上,广告的高度相同。 我正在使用添加底部的方法是通过将广告框的y值设置为视图的高度减去广告的高度。 这是我目前使用的代码: – (void)viewWillAppear:(BOOL)animated { CGRect adFrame = banner.frame; adFrame.origin.y = screenHeight – banner.frame.size.height; adFrame.size.width = screenWidth; banner.frame = adFrame; [banner setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth]; } – (void)viewDidLoad { [super viewDidLoad]; banner.frame = CGRectZero; } 任何帮助将非常感激。

使用Swift协议时发生短路

众所周知,从-Header.h文件中包含接口头文件是不可能的。 我的实际问题是,我有一个类的协议是Swift的一个定义: @protocol arrivingDelegate; @interface palettaTraffic : NSObject<MKMapViewDelegate, arrivingDelegate> { } 如果我导入* -Swift.h文件,当文件被包含在头文件中包含的另一个文件中时,我进入了丑陋的循环。 当我使用@protocol指令时,会发生这种情况:这是一个警告,但相当令人不安。 这就是swift协议的定义: @objc public protocol arrivingDelegate { func submitManualBusLine(busStripe:StripeProtocol) } 我还发现一个类似的post: Objective-C类中的Swift协议 但是这些build议似乎都不适用。

BAD_ACCESS(code = EXC_I386_GPFLT)用ECDSA签名时

我正在尝试在iOS上使用Crypto ++。 我从Marek Kotewicz的GitHub下载了预build版的图书馆。 我正努力从Crypto ++ wiki运行这个示例代码 。 ECDSA<ECP, CryptoPP::SHA256>::PrivateKey privateKey; ECDSA<ECP, CryptoPP::SHA256>::PublicKey publicKey; AutoSeededRandomPool prng, rrng; privateKey.Initialize(prng, CryptoPP::ASN1::secp256k1()); privateKey.MakePublicKey(publicKey); string signature; string message = "Do or do not. There is no try."; StringSource s(message, true, new SignerFilter(rrng, ECDSA<ECP, CryptoPP::SHA256>::Signer(privateKey), new StringSink(signature))); 它与下面的崩溃。 它出现在Xcode输出窗口中: BAD_ACCESS (code=EXC_I386_GPFLT) 这是C ++文件的memory.h中指向BAD_ACCESS的代码片段 _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 我得到BAD_ACCESS(代码= 1,地址= […]

Facebook SDK – 处理应用程序邀请?

使用Facebook SDK ,似乎他们允许您邀请您的朋友通过SDK的AppRequest部分join应用程序。 但是,我没有看到SDK中的任何地方,你可以奖励用户邀请朋友。 我知道这是可能的,因为它已经做了很多次了,所以怎么做呢? 例如,让我们说: 1. User A invites User B to use the application. 2. User B downloads the application. 3. User A receives 100 coins for inviting User B. 我完全迷失在这里,不pipe语言,使用任何SDK的例子,将不胜感激。

使用networking连接一次下载一个文件

我有一个array ,其中包含不同的url。 我想用进度条下载一个文件,而不是启动下一个文件等等。 这是我迄今为止的代码; -(void) func:(NSArray *) arry { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.timeoutIntervalForRequest = 900; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSMutableArray * downloadedUrl = [[NSMutableArray alloc] init]; for (NSString * str in arry) { NSURL *URL = [NSURL URLWithString:str]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; NSURLSessionDownloadTask downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL (NSURL […]

移动到Xcode 6后,iOS MkMapView空白

我使用mkMapView在Xcode 5中创build的应用程序运行良好。 最近在Xcode 6.1中创build了一个新的应用程序,并将旧的故事板场景和视图控制器拖到新的应用程序中。 地图视图现在显示一个空白屏幕,IOS 7上没有注释,但在IOS 8上工作。我添加了一个button,现在IOS 8上的地图视图也是空白的。 我删除并通过从对象模板中拖动视图控制器内的视图内的地图视图重新创build故事板中的视图。 地图仍然是空白的。 debugging后,我看到regionWillChangeAnimated和regionDidChangeAnimated显示重复的setRegion事件,将区域设置为0.0坐标(设置正确的区域之前和之后)。 最后从故事板视图中移除mkMapView并使用代码创build它。 //Create the map view _mkMapView = [[MKMapView alloc] initWithFrame:self.view.frame]; _mkMapView.mapType = MKMapTypeSatellite; _mkMapView.delegate = self; [self.view addSubview:_mkMapView]; [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; self.view.alpha = 1.0; _mkMapView.mapType = MKMapTypeStandard; _mkMapView.pitchEnabled = NO; //Set me as map delegate _mkMapView.delegate = self; 零setRegion事件现在不出现&地图工程确定。 故事板里有什么我应该设置的? 为什么故事板创build的视图会导致带有零坐标的重复setRegion事件?

如何使用AFJSONRequestOperation返回一个响应对象

我试图通过使用AFJSONRequestOperation获取天气数据。 问题是我不能在查询完成时返回对象。 有没有人知道如何做到这一点? 我目前的实施是 – (NSDictionary *)getCityWeatherData:(NSString*)city { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://free.worldweatheronline.com/feed/weather.ashx?key=xxxxxxxxxxxxx&num_of_days=3&format=json&q=%@", city]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSDictionary *data = [[JSON objectForKey:@"data"] objectForKey:@"weather"]; return data; } failure:nil]; [operation start]; }