我有这个代码:
// 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)
这就是我要找的.
谁能让我了解我做错了什么?
谢谢,
插口
这是问题代码:
代码是显示一个图像数组,然后可以滚动浏览.
- (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) 尝试在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)
任何人都可以解释什么是错的?我确定我已经正确导入了头文件..
谢谢,
插口
我在尝试使用以下代码安排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)
有人可以解释为什么没有显示本地通知?
提前致谢, …
我需要将以下方法从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) 我有一个我用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)
但是我的应用程序似乎无法找到该文件,任何人都可以解释我做错了什么?
我有一个UITableView,它填充了一个'Product'类型的对象数组,每个对象都有一个string类型的'name'属性.单击单元格时,将显示模态视图,其中包含有关该产品的更多信息.
我想要做的是根据名称属性的第一个字母将产品分成几个部分.(喜欢iPhone联系人).
我一直在努力解决这个问题,我似乎无法在网上找到解决我特定问题的任何内容.
有人能指出我正确的方向吗?
我有这段代码根据收到的本地通知调用不同的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) 我有这段代码,当我添加另一个对象时,我用它来更新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) 我有一个应用程序,我需要在一周的某些天发出通知(由用户定义).我之前使用过本地通知,但它总是相当直接,每天,每周等.但是,我从来没有必要同时在特定日期发出相同的通知.有没有人以前这样做过,可以对它有所了解?
ios ×8
iphone ×8
objective-c ×8
c# ×2
xamarin.ios ×2
arrays ×1
bitmap ×1
core-data ×1
enumeration ×1
facebook ×1
image ×1
mainbundle ×1
sorting ×1
string ×1
uitableview ×1