我喜欢按下按钮来切换电路板上的4个LED,就像
Click-1 --> LED 1 on
Click-2 --> LED 2 on
Click-3 --> LED 3 on
Click-4 --> LED 4 on
Click-5 --> LED 1 off
Click-6 --> LED 2 off
Click-7 --> LED 3 off
Click-8 --> LED 4 off
Click-9 --> LED 1 on
…
Run Code Online (Sandbox Code Playgroud)
到目前为止我有这个,但按钮点击检测没有按预期工作:
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>,
* Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试UITableView
使用按钮添加项目,这是我的代码:
在viewDidLoad
:repository = [[NSMutableArray alloc] initWithObjects: nil];
//ADD ITEM TO LIST
[repository addObject:repo]; //repository is a NSMutableArray
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:([repository count]-1) inSection:0];
NSLog(@"Indexpath to add row ----> %ld", (long)indexPath.row);
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationBottom];
[self.tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)
它现在将项目广告到列表中,但前提是它中已有一个Cell
UITableViewController like i configured here: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"NSMutableArray count in \"numbersOfRowsInSection\" ----> %lu", (unsigned long)[repository count]);
return [repository count] + 1;
}
Run Code Online (Sandbox Code Playgroud)
这是我的日志:
Indexpath to add row ----> <NSIndexPath: 0x10d9499a0> {length = 2, path …
Run Code Online (Sandbox Code Playgroud) 我想确定用户是否在"首选项"应用中关闭了"后台提取".如果他关闭它我的应用程序将无法正常工作.
嗨我喜欢全屏运行带有WebView init的OSx视图(当前屏幕不是Lion全屏模式那么大),有没有代码?
我喜欢在我的应用程序中显示IP地址,我已经知道如何显示WiFi IP地址但是当我在移动电话时它会显示错误,那么是否有一种方法可以在iPhone上显示移动IP地址?
这是我用于WiFi IP地址的代码:
NSString *address = @"error";
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
// retrieve the current interfaces - returns 0 on success
success = getifaddrs(&interfaces);
if (success == 0) {
// Loop through linked list of interfaces
temp_addr = interfaces;
while (temp_addr != NULL) {
if( temp_addr->ifa_addr->sa_family == AF_INET) {
// Check if interface is en0 which is the wifi connection on the iPhone
if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
// …
Run Code Online (Sandbox Code Playgroud) 我有一个问题,我使用UIScrollview创建了一个可缩放的UIImageView,一切都很完美,不再使用UIImageView不在中心,每次我隐藏工具和导航栏时,UIImageView/UIScrollView都会向上移动.
我已经设置了autoresizingMask:
scrollView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
scrollView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
Run Code Online (Sandbox Code Playgroud)
但它不起作用,有人可以帮助我吗?
我遇到了问题NSUserDefaults(suiteName: "group.app-ID")
.
我尝试将一个NSArray
存入NSUserDefaults
容器中的应用程序中viewDidLoad()
.
var defaults: NSUserDefaults = NSUserDefaults(suiteName: "group.app-ID")
defaults.setObject(["One", "Two"], forKey: "bookmarks")
defaults.synchronize()
Run Code Online (Sandbox Code Playgroud)
在我的TodayExtension中,我试着像这样得到数组:
扩展ViewController中的Globaly Defenition:
var defaults: NSUserDefaults = NSUserDefaults(suiteName: "group.app-ID")
var defaultsArray: NSArray!
Run Code Online (Sandbox Code Playgroud)
在 viewDidLoad()
defaultsArray = defaults.objectForKey("bookmarks") as NSArray
Run Code Online (Sandbox Code Playgroud)
但defaultsArray
总是如此nil
.
应用程序组权利已添加到所有目标.
我是PHP新手,但我喜欢创建一个脚本来检查我的MySQL数据库中是否有电子邮件,数据库名称是"Fily_Registrations"
,表是"用户"还是调用了值"email"
.所以基本上如果"hi@all.com"
我的数据库中存在电子邮件并且我调用php脚本就像"http://path/to/php.php?email=hi@all.com"
它应该回显"YES"
如果它不存在它应该回应"NO"
.
这就是我现在的票价,但总是回应"不":
<?php
$email = $_GET["email"];
$DataBase = "Fily_Registrations";
mysql_connect("server", "username", "password") or die(mysql_error());
mysql_select_db($DataBase) or die(mysql_error());
$string = sprintf("SELECT '$DataBase' FROM users WHERE email = '$email'");
$query = msql_query($string);
if($query == false) {
echo("No");
} else {
echo("Yes");
}
?>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这一问题?
有没有办法确定运行iOS TodayExtension的设备的设备类型.我无法在Swift中执行此操作.
我需要这样的东西:
-(BOOL)isiPad {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return NO;
}
}
Run Code Online (Sandbox Code Playgroud)
但是在Swift和TodayExtension中.
编辑:
let IS_IPAD = (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad);
Run Code Online (Sandbox Code Playgroud)
在iOS TodayExtensions中无效.
我正在编写一个可以访问iOS根系统的应用程序,用户应该能够将文件保存到他的文档目录中.我正在使用此代码将文件保存到文档目录.
对于文字:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[self.filePath writeToFile:[NSString stringWithFormat:@"%@/%@", documentsDirectory, [self.filePath lastPathComponent]]
atomically:YES
encoding:NSUTF8StringEncoding error:nil];
Run Code Online (Sandbox Code Playgroud)
对于其他文件:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[self.filePath writeToFile:[NSString stringWithFormat:@"%@/%@", documentsDirectory,[self.filePath lastPathComponent]]
atomically:YES];
Run Code Online (Sandbox Code Playgroud)
我的问题是我可以保存.txt文件,但不保存其他文件.如果我使用保存文本方法保存例如.plist文件,则联系人将替换为文件的目录路径.当我保存图片或任何其他文件时,它是不可读的.有没有一种很好的方法来保存文件而不会破坏它们?
ios ×6
objective-c ×2
swift ×2
background ×1
c ×1
database ×1
fullscreen ×1
ios7 ×1
ip-address ×1
libopencm3 ×1
macos ×1
mysql ×1
php ×1
uiimageview ×1
uiscrollview ×1
uitableview ×1
webview ×1
writetofile ×1
xcode ×1