我正在尝试实现类似于a Touch Up Inside的触摸事件UIButton.我看过一些代码使用touchesBegan:withEvent但看起来我需要在屏幕上滑动一下手指.我其实只想触摸图像
码:
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
NSLog(@"Image touched!");
}
Run Code Online (Sandbox Code Playgroud)
问候!
Hy伙计们,
我正在尝试使用ICSharpCode.SharpZipLib库生成一个Zip文件,但它抛出了一个非常奇怪的错误.
码:
public static void ZipFiles(string inputFolderPath, string outputPathAndFile, string password)
{
ArrayList ar = GenerateFileList(inputFolderPath); // generate file list
int TrimLength = (Directory.GetParent(inputFolderPath)).ToString().Length;
TrimLength += 1; //remove '\'
FileStream ostream;
byte[] obuffer;
ZipOutputStream oZipStream = new ZipOutputStream(File.Create(outputPathAndFile)); // create zip stream
if (password != null && password != String.Empty)
oZipStream.Password = password;
oZipStream.SetLevel(9); // maximum compression
ZipEntry oZipEntry;
foreach (string Fil in ar) // for each file, generate a zipentry
{
oZipEntry = new ZipEntry(Fil.Remove(0, TrimLength));
oZipStream.PutNextEntry(oZipEntry);
if …Run Code Online (Sandbox Code Playgroud) 我一直在寻找两者之间的差异(通常用于使用HTTP/HTTPS的简单请求),但我找不到任何东西.有什么区别吗?我问它,因为当我需要,我只是使用NSURLConnection的,我已经看到了很多人建议使用AFNetworking(基于CFNetwork的).
问候!
我的应用程序中有一个嵌入式数据库,它具有一些感兴趣点的纬度和经度,我需要知道我与这些点的距离(使用GPS获取我的位置).我的问题是:我刚刚发现SQLite无法使用我的查询计算距离,因为它不计算三角函数(SIN,COS ...).我试图避免使用此查询以编程方式计算这些距离:
NSLog(@"SELECT ((ACOS(SIN(%@ * PI() / 180) * SIN(lat * PI() / 180) + COS(%@ * PI() / 180) * COS(lat * PI() / 180) * COS((%@ – lon) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance` FROM `members` HAVING `distance`<=’1000? ORDER BY `distance`", Latitude,Latitude, Longitude);
Run Code Online (Sandbox Code Playgroud)
有人有解决方案吗?
问候!
我有一个.xlsx文件,我打开这个代码:
import pandas as pd
df = pd.read_excel(open('file.xlsx','rb'))
df['Description'].head
Run Code Online (Sandbox Code Playgroud)
我有以下结果,看起来很不错.
ID | Description
:----- | :-----------------------------
0 | Some Description with no hash
1 | Text with #one hash
2 | Text with #two #hashes
Run Code Online (Sandbox Code Playgroud)
现在我想创建一个新列,只保留以#开头的单词,如下所示:
ID | Description | Only_Hash
:----- | :----------------------------- | :-----------------
0 | Some Description with no hash | Nan
1 | Text with #one hash | #one
2 | Text with #two #hashes | #two #hashes
Run Code Online (Sandbox Code Playgroud)
我能用#计算/分隔线:
descriptionWithHash = df['Description'].str.contains('#').sum()
Run Code Online (Sandbox Code Playgroud)
但现在我想像上面描述的那样创建列.最简单的方法是什么?
问候!
PS:它应该在问题中显示表格格式,但我无法弄清楚它为什么显示错误!
在某些情况下,我需要在1天内增加一个NSDate.对于它,我使用dateByAddingTimeInterval,但它不起作用.
这是代码:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy HH:mm"];
NSString *startDate = [NSString stringWithFormat:@"%@/2012 %@",dayString, begin];
NSString *endStringForDate = [NSString stringWithFormat:@"%@/2012 %@",dayString, end];
NSLog(@"Csantos: event starts: %@, event ends: %@", startDate, endStringForDate);
NSDate *beginDate = [dateFormat dateFromString:startDate];
NSDate *endDate = [dateFormat dateFromString:endStringForDate];
NSComparisonResult result = [beginDate compare:endDate];
if(result == NSOrderedDescending){
NSTimeInterval dayinseconds = 24 * 60 * 60;
[endDate dateByAddingTimeInterval:dayinseconds];
NSLog(@"Csantos: event ends: %@", endDate);
}
Run Code Online (Sandbox Code Playgroud)
结果:
2012-01-24 12:09:47.837 app[3689:207] Csantos: event starts: 19/02/2012 23:00, event ends: 19/02/2012 …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置UIDatePicker的日期,但我每个月都是"1月"(01).我尝试使用"MM"和"LL",但两者都不起作用.
我的代码:
-(void)viewDidLoad {
[super viewDidLoad];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYY-MM-DD"];;
NSDate *anyDate = [dateFormat dateFromString:@"2019-09-11"];
[datePicker setDate:anyDate];
[dateFormat release];
Run Code Online (Sandbox Code Playgroud)
}
提前致谢,
克劳迪奥
我正在尝试使用此代码在数据库上插入一些数据:
-(void)insertLocationOnDatabase:(LocationType *)aLocation {
sqlite3_stmt *stmt;
int location = [aLocation.locationID intValue];
NSLog(@"Location ID: %i", location);
const char *sql = "insert into tbl_location values (?,?,?,?)";
if (sqlite3_prepare_v2(database, sql, -1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_int(stmt, 0, location);
sqlite3_bind_text(stmt, 1, [aLocation.Description UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, [aLocation.isActive UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 3, [aLocation.sequenceOrder UTF8String], -1, SQLITE_TRANSIENT);
if (sqlite3_step(stmt) == SQLITE_DONE) {
NSLog(@"Location %@ inserted on database",aLocation.Description);
}
else {
NSLog(@"Error on step: %i",sqlite3_errcode(database));
}
}
else {
NSLog(@"Error on prepare: %i",sqlite3_errcode(database));
} …Run Code Online (Sandbox Code Playgroud) iphone ×4
ios ×2
cfnetwork ×1
geolocation ×1
nsdate ×1
nsstring ×1
pandas ×1
python ×1
sqlite ×1
uidatepicker ×1
uiimageview ×1
xamarin.ios ×1
xaml ×1
zip ×1