小编Red*_*Mak的帖子

拖放到NSView中

我是在一个NSView中拖放,但从draggingEntered:未被调用过.代码:

#import <Cocoa/Cocoa.h>
@interface testViewDrag : NSView <NSDraggingDestination>
@end

@implementation testViewDrag
- (id)initWithFrame:(NSRect)frame
{
   self = [super initWithFrame:frame];
   if (self)
{
    [self registerForDraggedTypes:[NSImage imagePasteboardTypes]];
    NSLog(@"initWithFrame");
}
return self;
}

-(NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
{
NSLog(@"draggingEntered");
return NSDragOperationEvery;
}

-(NSDragOperation) draggingUpdated:(id<NSDraggingInfo>)sender
{
  NSLog(@"draggingUpdated");
  return NSDragOperationEvery;
}
@end
Run Code Online (Sandbox Code Playgroud)

在界面构建器中,我将一个subView(类设置为testViewDrag)添加到主窗口.在日志中我可以看到initWithFrame日志,但是当我拖动时,日志中不会显示任何内容.

我错过了什么?

macos drag-and-drop nsdragginginfo

3
推荐指数
1
解决办法
6603
查看次数

无法在iPhone应用程序中使用Base64上传图片

我之前在这个论坛上问这个,但它已经关闭我不知道为什么,所以我再次发布我的问题.在iPhone应用程序中我必须使用Base64编码上传图片,但当我在服务器中查看图片全白(大小= 0x0,54 KO),我确定我的图片的Base64编码是正确的,因为我有一个PHP脚本,我使用它,图片正常显示.这是用于上传的PHP代码:

<?php
$filename = "photo_to_upload.jpg";
$handle = fopen($filename, "r");
$imgbinary = fread($handle, filesize($filename));
$data = base64_encode($imgbinary);
fclose($handle);
?>
<img src="./<?php echo $filename ?>" />
<form action="http://host" method="POST">
<input type="hidden" name="data" value="<?php echo $data?>">
<input type="submit" value="envoyer" />
</form>
Run Code Online (Sandbox Code Playgroud)

和Xcode我用这个:

 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"photo_to_upload" ofType:@"jpg"];
 NSURL *url = [NSURL fileURLWithPath:filePath]; 
 NSData *imageData = [NSData dataWithContentsOfURL:url];

 NSURLResponse* response;
 NSError* error=nil;

NSMutableData *postData=[[NSMutableData alloc]init];
[postData appendData:[@"data=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[self base64forData:imageData]];


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL   URLWithString:@"HOST"]];
[request setHTTPMethod:@"POST"];
[request …
Run Code Online (Sandbox Code Playgroud)

iphone upload base64

2
推荐指数
1
解决办法
2492
查看次数

Import provisioning profile to other mac from apple site

I have a mac with contain my apple provisioning profile, this mac is "died", now i want to work with other mac, how can import my old provisioning profile ( with the apple certification ) ? thank you.

iphone certificate provisioning ios

1
推荐指数
1
解决办法
3746
查看次数

NSArrayController+cocoa 绑定+核心数据:在应用程序启动时获取选定的行

我正在使用可可绑定、NSArrayController 和核心数据。启动后,应用程序必须获取第一项,我在 applicationDidFinishLaunching 中尝试此操作:

1. Entity *ent = arrayManager.arrangedObjects[0];

2. Entity *ent = arrayManager.selectedObjects[0];
Run Code Online (Sandbox Code Playgroud)

---> 错误说数组为空。为什么 ?

我不明白的另一件事是,当应用程序出现时,在 tableView 中有一个选定的行,但是当我记录时:

NSLog(@"selected row in applicationDidFinishLaunching = %li",self.TableViewController.tableView.selectedRow);
Run Code Online (Sandbox Code Playgroud)

log: -1--> 没有选择行!为什么 ?

macos nsarraycontroller cocoa-bindings

1
推荐指数
1
解决办法
561
查看次数