小编Jac*_*ins的帖子

目标 - C新秀NSString问题

我有这个代码:

// Fill out the email body text
NSString *emailBody = (@"Name:%@\nNumber of People:\nDate:", name.text);
NSLog(@"%@", emailBody);
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在尝试将name.text附加到"Name:"之后的电子邮件正文中.但是,NSLog仅输出name.text中包含的字符串,而不输出电子邮件正文的其余部分.我在这里做错了,代码除了name.text之外还删除了字符串的其余部分?

EG如果name.text包含文本"Jack",则NSLog只输出"Jack"而不是:

Name: Jack
Number of People: x 
Date: x
Run Code Online (Sandbox Code Playgroud)

这就是我要找的.

谁能让我了解我做错了什么?

谢谢,

插口

string iphone objective-c ios

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

试图显示图像数组,代码将iphone返回主屏幕

这是问题代码:

代码是显示一个图像数组,然后可以滚动浏览.

- (void)viewDidLoad {
    [super viewDidLoad];

    NSArray *photos = [[NSArray arrayWithObjects:   
                        [UIImage imageNamed:@"Event.png"],
                        [UIImage imageNamed:@"Logo.png"],
                        [UIImage imageNamed:@"default.png"],
                        [UIImage imageNamed:@"LittleLogoImage.png"],
                        nil] retain];      // TODO – fill with your photos

    // note that the view contains a UIScrollView in aScrollView

    int i=0;
    int width = 0;
    int height = 0;
    for ( NSString *image in photos )
    {
        UIImage *image = [UIImage imageNamed:[photos objectAtIndex:i]];
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        imageView.clipsToBounds = YES;

        imageView.frame = CGRectMake( imageView.frame.size.width * …
Run Code Online (Sandbox Code Playgroud)

arrays iphone image objective-c ios

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

没有找到i386架构的Facebook符号

尝试在xcode 4中编译项目时出现以下错误(在xcode 3.x中正常工作)

    Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_FBSession", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBLoginDialog", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBRequest", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBStreamDialog", referenced from:
      objc-class-ref in View1Controls.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释什么是错的?我确定我已经正确导入了头文件..

谢谢,

插口

iphone facebook objective-c linker-errors ios

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

UILocalNotification - 通知未显示

我在尝试使用以下代码安排UILocalNotification时遇到问题:

    - (IBAction) createNotification {
    //Just to verify button called the method
    NSLog(@"createNotification");

    NSString *dateString = dateTextField.text;

    NSString *textString = textTextField.text;

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd-yyyy HH:mm"];
    [formatter setTimeZone: [NSTimeZone defaultTimeZone]];

    NSDate *alertTime = [formatter dateFromString:dateString];

    UIApplication *app = [UIApplication sharedApplication];

    UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease];
    if(notification){
        notification.fireDate = alertTime;
        notification.timeZone = [NSTimeZone defaultTimeZone];
        notification.repeatInterval = 0;
        notification.alertBody = textString;

        [app scheduleLocalNotification:notification];

        NSLog(@"%@", dateString);
    }
}
Run Code Online (Sandbox Code Playgroud)

当我按下按钮并且我传入以下日期字符串时,正确调用代码:

02-12-2012 19:01

  • 我也试过了

02/12/2012 19:01

无济于事.(我根据测试时间相应地改变时间,例如21:06)

有人可以解释为什么没有显示本地通知?

提前致谢, …

iphone objective-c uilocalnotification

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

将标准C#转换为符合MonoTouch标准的代码

我需要将以下方法从C#转换为符合MonoTouch的代码:

private WritableBitMap CreateBitMapWPF(RGBPaletteRecord rgbPalette, double dpi)
        {
            WritableBitMap bitmapImage = null;

            try
            {
                bitmapImage = new WritableBitMap(TileRecord.PixelWidth, TileRecord.PixelHight, dpi, dpi, PixelFormats.Rgb24, BitmapPalettes.Halftone256);
              //  int nStride = (bitmapImage.PixelWidth * bitmapImage.Format.BitsPerPixel + 7) / 8;
                int nStride = (bitmapImage.PixelWidth * bitmapImage.Format.BitsPerPixel  / 8);
                System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, 0, TileRecord.PixelWidth, TileRecord.PixelHight);

                byte[] data = GetBytes(rgbPalette);

                bitmapImage.WritePixels(rect, data, nStride, 0);
            }
            catch (Exception ex)
            {

            }

            //// temp write to file to test         
            //using (FileStream stream5 = new FileStream(@"C:\test.bmp", FileMode.Create))
            //{

            // …
Run Code Online (Sandbox Code Playgroud)

c# bitmap xamarin.ios

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

MonoTouch - 从主包中读取文件

我有一个我用MonoTouch编写的应用程序.我将名为ARCSDev的文件放入application文件夹并将其包含在项目中,然后我尝试使用以下代码读入该文件:

private void generateChart (int chartNumber, string palette)
        {
            string path = Environment.GetFolderPath (Environment.SpecialFolder.Personal); 
            string filePath = Path.Combine(path, "ARCSDev");

            Loader loader = new Loader (filePath);
Run Code Online (Sandbox Code Playgroud)

但是我的应用程序似乎无法找到该文件,任何人都可以解释我做错了什么?

c# xamarin.ios ios mainbundle

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

基于字符串属性按字母顺序对对象数组进行排序

我有一个UITableView,它填充了一个'Product'类型的对象数组,每个对象都有一个string类型的'name'属性.单击单元格时,将显示模态视图,其中包含有关该产品的更多信息.

我想要做的是根据名称属性的第一个字母将产品分成几个部分.(喜欢iPhone联系人).

我一直在努力解决这个问题,我似乎无法在网上找到解决我特定问题的任何内容.

有人能指出我正确的方向吗?

sorting iphone objective-c uitableview ios

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

如何判断收到了哪些本地通知?目标 - C.

我有这段代码根据收到的本地通知调用不同的NSLog语句:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
    if (notification == automaticBackupNotification)
    {
        NSLog(@"Backup notification received.");
    }
    else
    {
        NSLog(@"Did receive notification: %@, set for date:%@ .", notification.alertBody, notification.fireDate);
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用此方法在另一个类中安排通知:

- (IBAction)automaticValueChanged {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (automaticSwitch.isOn){
        [defaults setValue:@"1" forKey:@"automatic"];
        //schedule notification
        //Set up the local notification
        appDelegate.automaticBackupNotification = [[UILocalNotification alloc] init];
        if(appDelegate.automaticBackupNotification){
            //Repeat the notification according to frequency
            if ([backupFrequencyLabel.text isEqualToString:@"Daily"]) {
                appDelegate.automaticBackupNotification.repeatInterval = NSDayCalendarUnit;
            }
            if ([backupFrequencyLabel.text isEqualToString:@"Weekly"]) {
                appDelegate.automaticBackupNotification.repeatInterval = NSWeekCalendarUnit;
            }
            else { …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uilocalnotification

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

错误:在访问全局变量和核心数据时,NSArray在被枚举时被突变

我有这段代码,当我添加另一个对象时,我用它来更新Core Data中的一些值:

//Create new receipt
        Receipt *receipt = [[Receipt alloc] init];
        receipt.project = self.projectLabel.text;
        receipt.amount = self.amountTextField.text;
        receipt.descriptionNote = self.descriptionTextField.text;
        receipt.business = self.businessNameTextField.text;
        receipt.date = self.dateLabel.text;
        receipt.category = self.categoryLabel.text;
        receipt.paidBy = self.paidByLabel.text;
        receipt.receiptImage1 = self.receiptImage1;
        //Need to set this to 2
        receipt.receiptImage2 = self.receiptImage1;
        receipt.receiptNumber = @"99";

        int count = 0;
        int catCount = 0;

    for (Project *p in appDelegate.projects)
            {
                if ([p.projectName isEqualToString:receipt.project]){
                    double tempValue = [p.totalValue doubleValue];
                    tempValue += [receipt.amount doubleValue];
                    NSString *newTotalValue = [NSString stringWithFormat:@"%.02f", tempValue];
                    NSString …
Run Code Online (Sandbox Code Playgroud)

iphone enumeration core-data objective-c ios

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

仅在特定日期触发UILocalNotification

我有一个应用程序,我需要在一周的某些天发出通知(由用户定义).我之前使用过本地通知,但它总是相当直接,每天,每周等.但是,我从来没有必要同时在特定日期发出相同的通知.有没有人以前这样做过,可以对它有所了解?

iphone objective-c ios uilocalnotification

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