Tag: 目标C

调用块内块后的不良访问(iOS)

我有一个块,我正在从firebase检查用户的状态属性。 如果status属性是'free',我想从块中返回,否则我想search另一个用户并检查他们的状态,直到find'free'用户: void( ^ myResponseBlock)(BOOL finished) = ^ void(BOOL finished) { if (finished) { if ([self.freedom isEqualToString: @"free"]) { NSLog(@"free!"); return; } else if ([self.freedom isEqualToString: @"matched"]) { NSLog(@"get another user"); //get another user do { //picking another random user from array rando = arc4random_uniform(arraycount); } while (rando == randomIndex && rando == [self.randString intValue]); […]

设置CTStringAttributes字体后无法访问string大小

我正在尝试使用string和特定字体呈现一个CATextLayer。 如果使用CATextLayer设置字体,字体不会正确呈现。 如果我在CTStringAttributes中设置字体,那么我得到以下错误: Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFType screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x13dba570 这是我想要使用的代码: CTStringAttributes ctsa = new CTStringAttributes(); //This method returns what out kerning should be loosely based on the //tracking number our UI designer uses in Adobe Illustrator var trackingSize = MyFonts.IllustratorTracking(200f * 0.8f, MyFonts.CardHeader.PointSize); ctsa.KerningAdjustment […]

如何用混响效果保存录制的audio

我正在使用theamazingaudioengine录制,播放和添加像iOS应用程序的混响效果。 我可以录制,播放录制的audio以及混响效果。 但是我无法将具有混响效果的audio文件保存到图库中。 任何人都可以帮助我这个。 我正在保存录制的audio。 ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; NSArray *documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [[documentsFolders objectAtIndex:0] stringByAppendingPathComponent:@"Recording.aiff"]; [library writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:path] completionBlock:^(NSURL *assetURL, NSError *error){ /*notify of completion*/ NSLog(@"AssetURL: %@",assetURL); NSLog(@"Error: %@",error); if (!error) { //video saved [[self appDelegate] showAlertWithTitle:@"Audio Saved" message:@""]; } else{ [[self appDelegate] showAlertWithTitle:@"Error" message:error.domain]; } }]; […]

编译OpenCV for iOS失败

有没有人知道为什么会出现这个错误? 我运行$ python platforms/ios/build_framework.py ios来创build适用于iOS的OpenCV framework 。 但安装失败。 平台信息:今天OpenCV最新提交,CMake 2.8.12.2,XCode 5.1.1,Mac OSX 10.9.2 我遵循本教程: 安装Opencv For iOS ** INSTALL FAILED ** The following build commands failed: Libtool ios/build/iPhoneSimulator-x86_64/modules/world/UninstalledProducts/libopencv_world.a normal x86_64 (1 failure) Traceback (most recent call last): File "platforms/ios/build_framework.py", line 112, in <module> build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1])) File "platforms/ios/build_framework.py", line 104, in build_framework put_framework_together(srcroot, dstroot) File […]

如何在目标c中设置图像位置程序?

我想将图像移动到另一个x,y坐标3秒后我尝试这个,但我得到这样的错误:2012-01-17 14:01:11.417 YapiKrediDemo [2147:207] – [Sozlesme moveImage]:无法识别的select器发送到实例0x6e07540我的代码是: – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. image1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"GirisButton.png"]]; [self.view addSubview:image1]; [NSTimer scheduledTimerWithTimeInterval: 3 target: self selector:@selector(moveImage) userInfo: nil repeats:YES]; } – (void)moveImage:(NSTimer*)timer{ //[image1 setCenter: CGPointMake(634, 126)]; CGRect myFrame = image1.frame; myFrame.origin.x = 634; myFrame.origin.y = […]

如何直接使用FTP将图像上传到服务器目录

我已经search了很多关于如何从我的相机胶卷上载图像到服务器目录,我没有find任何东西!所以我已经从苹果(SimpleFTPSample)下载了示例代码,我把这些代码吼: – (void)_startSend:(NSString *)filePath { BOOL success; NSURL * url; CFWriteStreamRef ftpStream; assert(filePath != nil); assert([[NSFileManager defaultManager] fileExistsAtPath:filePath]); assert( [filePath.pathExtension isEqual:@"png"] || [filePath.pathExtension isEqual:@"jpg"] ); assert(self.networkStream == nil); // don't tap send twice in a row! assert(self.fileStream == nil); // ditto // First get and check the URL. url = [[AppDelegate sharedAppDelegate] smartURLForString:self.urlText.text]; success = […]

请求失败:“AFMultipartFormData”中的错误请求(400)

我正在与目标c的networking工作。 我的参数types是“formData”。 所以我使用“AFMultipartFormData” 这是我的代码 NSLog(@"enter in requestPostFormData"); AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"application/json"]; [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [manager.requestSerializer setValue:strAuthorization forHTTPHeaderField:@"Authorization"]; return [manager POST:baseURL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData){ //passing parameter NSMutableData *name = [[NSMutableData alloc]init]; [name appendData:[[NSString stringWithFormat:@"asha"] dataUsingEncoding:NSUTF8StringEncoding]]; formData appendPartWithFormData:name name:@"name"]; }success:^(NSURLSessionDataTask *task, id responseObject) { […]

如何在DialogViewController上将背景设置为透明

当我将MonoTouch.Dialog背景颜色设置为uiclear(透明)时,它会抛出exception,为什么? 以及如何将其设置为透明。 未处理的exception:System.NullReferenceException:未将对象引用设置为MyDialogViewController.LoadView()中MyDialogViewController.cs中的[0x00016]对象引用:ParentViewController.View.BackgroundColor = UIColor.Clear public class MyDialogViewController: DialogViewController { public MyDialogViewController (RootElement root) : base (root) { } public override void LoadView() { base.LoadView (); this.TableView.BackgroundColor = UIColor.Clear; ParentViewController.View.BackgroundColor = UIColor.Clear; } } public void xxxxx(){ var menu = new RootElement(""){ new Section ("Demo"){ new EntryElement("Name", "",""), }, }; var menuDVC = new MyDialogViewController […]

NSNetServiceBrowser找不到服务

我试图编写基于CocoaEcho示例的客户端(iPad)/服务器(iMac)应用程序。 我的第一个简单的例子工作,但添加更多的function后,客户端无法find服务器。 启动服务器后,我启动客户端,都在本地networking。 客户端开始search服务,并为其浏览器获取“netServiceBrowserWillSearch:”消息,但之后没有任何反应。 再次触发对服务的search,导致出现错误-72003,10(浏览器仍在忙于search)的“didNotsearch:”消息。 1)我检查了服务器与WiTap应用程序可达。 有客户端和服务器连接正确。 2)我检查是否服务器发布“dns-sd -B _cocoaecho”的服务,它被检测到。 3)客户端应用程序中的nsnetservicebrowser对象被声明为一个属性,所以不应该有一个范围问题。 我也检查了debugging器,它仍然存在…. 我的代码: 客户: @interface MySocketClient : UIResponder <NSNetServiceBrowserDelegate, NSStreamDelegate> { … NSNetService * myServer; NSString* nextMsg; } @property (nonatomic, strong, readwrite) NSMutableArray * services; // of NSNetService @property (nonatomic, strong, readwrite) NSNetServiceBrowser * serviceBrowser; @property (nonatomic, strong, readwrite) NSInputStream * inputStream; @property (nonatomic, strong, […]

iOS获取Parse Facebook好友名字和分数

我从Parse获取Facebook朋友列表,并将其所有数据存储在任何Array中。 例如: ( "<PFUser:npzU2fuydD:(null)> { \n HS = 99; \n fbId = 1000000000000000; \n profile = { \n facebookId = 100000748420227; \n name = \"Name Lastname"; \n pictureURL = \"https://graph.facebook.com/100000000000000/picture?type=large&return_ssl_resources=1\"; \n }; \n username = k49vitcfqbb22p0pu40ejy6oh;\n}" 代码如下: [FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (!error) { // result will contain an array with […]