我可以使用以下jQuery代码使用Ajax请求的post方法执行文件上载吗?
$.ajax({
type: "POST",
timeout: 50000,
url: url,
data: dataString,
success: function (data) {
alert('success');
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
如果可能,我是否需要填写"数据"部分?这是正确的方法吗?我只将文件发布到服务器端.
我一直在谷歌搜索,但我发现是一个插件,而在我的计划中,我不想使用它.至少目前.
我有主要的UIView,我在那里显示不同的数据.然后我放了一个按钮,显示如下子视图:
- (IBAction) buttonClicked:(id)sender
{
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(25,25,50,20)];
UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(25,25,50,25)];
newLabel.text = @"some text";
[newView addSubview:newLabel];
[self.view addSubview:newView];
[newLabel release];
[newView release];
}
Run Code Online (Sandbox Code Playgroud)
newView看起来很好,但它不会以任何方式动画,它只会立即出现.当newView出现时,如何添加某种动画?像缩放或向下滑动或类似的东西.有一些简单的代码吗?
男人,难倒在这一个.尝试使用AFNetworking下载文件,我能做的最好的事情是捕获downloadProgressBlock中的进度字节.我已经尝试了许多不同的AFNetworking分叉,现在我又回到了最新版本.看起来曾经AFHTTPRequestOperation被修改为也包括NSURLResponse但在最新版本中已经消失了.并且,根据下面的代码,永远不会调用"成功"块.我得到下载字节的日志,然后调用^ complete.从未调用成功与错误.
对此的任何指导都很棒.我无法弄清楚返回数据的位置以及如何让它使用NSFileManager?我需要下载文件,而不是为图像写入流等.
编辑:我还尝试通过覆盖 - (void)连接捕获数据:didReceiveData,如文档中所建议的那样,但没有做任何事情.
// url是http://mydomain.com/somezip.zip
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", url]]];
AFHTTPRequestOperation *operation = [AFHTTPRequestOperation HTTPRequestOperationWithRequest:request success:^(id object) {
NSLog(@"hey, some success!");
} failure:^(NSHTTPURLResponse *response, NSError *error) {
NSLog(@"%@", error);
}];
[operation setDownloadProgressBlock:^(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead) {
// callback is sent in and works great. Just outputting to the console at the moment
SEL callme = NSSelectorFromString(callback);
[sender performSelectorOnMainThread:callme withObject:[NSNumber numberWithInt:bytesRead] waitUntilDone:NO];
}];
[operation setCompletionBlock:^{
NSLog(@"operation complete");
}];
NSOperationQueue *queue …Run Code Online (Sandbox Code Playgroud) 我正在使用电子邮件权限打开facebook会话,如下所示:
- (void)facebookOpenSession {
NSArray *permissions = @[@"email"];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
Run Code Online (Sandbox Code Playgroud)
然后会话状态的重要片段改变如下:
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error {
switch (state) {
case FBSessionStateOpen: {
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
//error
} else {
self.myFirstNameLabel.text = user.first_name;
self.myLastNameLabel.text = user.last_name;
// self.myEmailLabel.text = @"";
}
}];
}
...
Run Code Online (Sandbox Code Playgroud)
我如何实际提取用户的电子邮件?它是在一个提供的变量中,还是我必须在完成处理程序中进行另一个调用?
提前致谢!
我将参与一个涉及Paypal功能的项目.我的问题是我需要做什么样的帐户来进行测试?我需要商家帐户吗?
如果您还有一个很好的参考站点,请在此处分享.
谢谢
我正在尝试调试我的应用程序崩溃的原因.从我的审判中我意识到,在某个地方,有泄漏,我正在搞清楚.我知道它是因为当我在这里使用这种方法尝试调试时,它最终会崩溃,因为看起来内存泄漏在一段时间后会膨胀.
为了找出原因,我现在在XCode 4上打开NSZombieEnabled为YES但是我没有看到任何内容.所以现在我转向崩溃日志.这是:
Thread 7 Crashed:
0 libsystem_kernel.dylib 0x31b71a1c __pthread_kill + 8
1 libsystem_c.dylib 0x35ceb3b4 pthread_kill + 52
2 libsystem_c.dylib 0x35ce3bf8 abort + 72
3 libsystem_c.dylib 0x35d1f024 free + 104
4 ImageIO 0x32ca35f0 ImageProviderReleaseInfoCallback + 56
5 CoreGraphics 0x31a05284 image_provider_finalize + 8
6 CoreFoundation 0x35aad288 _CFRelease + 160
7 CoreFoundation 0x35aad1ae CFRelease + 82
8 CoreGraphics 0x319fe150 CGImageProviderRelease + 4
9 CoreGraphics 0x31a00bac CGImageBlockSetRelease + 44
10 CoreGraphics 0x31a00b70 img_blocks_destroy + 8
11 CoreGraphics 0x319fdaae CGSImageDataUnlock + 26 …Run Code Online (Sandbox Code Playgroud) 据我所知,如果设备上安装了多个具有不同App ID的应用程序,则为每个应用程序生成的推送通知令牌应该是唯一的.
在我的例子中,我有几个使用不同配置文件编译的应用程序,每个应用程序都基于不同的应用程序ID(尽管其中一些具有相同的Bundle Seed ID,有些则没有).
对于每个应用程序,我生成了开发推送通知SSL并导出SSL以生成PEM.接下来,我下载配置文件并将其应用于XCode.
当我试图在我的设备上运行它时,我得到的是:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
Run Code Online (Sandbox Code Playgroud)
所有应用程序都是一个相同的设备令牌.我想知道为什么会这样?
当我试图通过我的服务器推送通知时,没有收到任何错误消息.但通知从未传递给已安装的设备.
请给我关于这个问题的建议.提前致谢.
objective-c ×3
ios ×2
iphone ×2
afnetworking ×1
ajax ×1
animation ×1
debugging ×1
facebook ×1
file-upload ×1
javascript ×1
jquery ×1
paypal ×1
php ×1
post ×1
uiview ×1
xcode4 ×1