【发布时间】:2012-01-13 01:11:00
【问题描述】:
我正在尝试为 iphone 制作一个应用程序,它将向指定的 urf(或 Web 应用程序)发送一个 tcp 连接。我希望按钮在发送前首先发出警报。我为此写了这段代码:
-(IBAction)tiklandi:(id)sender{
NSString *buton1 = [sender titleForState:UIControlStateNormal];
NSString *uyariText = [[NSString alloc] initWithFormat:@"istek gönderiliyor!"];
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Sunucuya Gönderildi" message:uyariText delegate:nil
cancelButtonTitle:@"işlemi iptal ettiniz!"
otherButtonTitles: nil];
[alert show];
//[alert release];
但我无法在我的代码中使用任何 url 方法。
我的第二个问题是,我在 Developer 目录和 Xcode 的项目导航器中看不到我的界面构建器,我看不到文件夹,所有的类都相互混合。我使用的是 Xcode 4.2,我对所有这些都是新手,有人可以帮忙吗?
我尝试了列出的解决方案,但我不知道如何交互我的视图控制器文件和 .xib 文件。 这是我的视图控制器 .h 文件:
@interface ViewController : UIViewController
@property (nonatomic, retain) NSURLRequest *url;
@property (nonatomic,retain) UIButton *buton;
-(IBAction)fonksiyon:(id)sender;
@end
这是我的实现文件(视图控制.. .m)
#import "ViewController.h"
@implementation ViewController
@synthesize buton;
@synthesize url;
-(IBAction)fonksiyon:(id)sender{
NSString *buton= [sender titleForState:UIControlStateNormal];
NSURL *url= [sender url];
NSString *uyariText= [[NSString alloc] initWithFormat:@"gönderiliyor!"];
UIAlertView *alertView= [[UIAlertView alloc]initWithTitle:@"Sunucuya Gönderildi"
message:uyariText
delegate:self
cancelButtonTitle:@"işlemi iptal ettiniz!"
otherButtonTitles:@"Server'a Git!", nil];
- (NSURL)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://192.168.69.290/cgi-bin/ipad.pl";nil]];
}
}
}
问题是我无法通过文件所有者在 .xib 文件和其他文件之间建立关系。据我了解,当我从文件所有者那里拖动时,我也应该看到我的函数(这里称为 fonksiyon)。有人可以帮忙吗?
【问题讨论】:
标签: iphone xcode interface-builder