我想玩UIPopupController,我明白我无法检测到我的popover解雇.我的步骤:
1.从XCode创建示例(文件 - >新建项目 - >实用应用程序)
2.添加到MainViewController.hUIPopoverControllerDelegate
#import "FlipsideViewController.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate,UIPopoverControllerDelegate>
@property (strong, nonatomic) UIPopoverController *flipsidePopoverController;
- (IBAction)showInfo:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
- (IBAction)showInfo:(id)sender
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
} else {
if (!self.flipsidePopoverController) {
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil];
controller.delegate = self;
self.flipsidePopoverController.delegate = self
self.flipsidePopoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
}
if ([self.flipsidePopoverController isPopoverVisible]) {
[self.flipsidePopoverController … 我需要抓住特殊区域的滑动动作.但是调试器说unrecognized selector sent to instance
- (void)viewDidLoad
{
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
initWithTarget:self.viewName action:@selector(didSwipe:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
}
-(void)didSwipe:(UISwipeGestureRecognizer*)swipe{
NSLog(@"swiped left");
}
Run Code Online (Sandbox Code Playgroud)
怎么了?
是的,我知道,这是常见的问题,但我在最近3个小时内无法解决.
我这样查询:
$query = 'UPDATE `'.$masterapp_users_table.'` SET `login` = "'.htmlspecialchars(strip_tags($_POST['login'])).'", `pass` = "'.md5(htmlspecialchars(strip_tags($_POST['pass']))).'", `email` = "'.htmlspecialchars(strip_tags($_POST['email'])).'", `firstname` = "'.htmlspecialchars(strip_tags($_POST['fn'])).'", `secondname` = "'.htmlspecialchars(strip_tags($_POST['sn'])).'" WHERE `login` = "'.htmlspecialchars(strip_tags($_POST['previouslogin'])).'"';
echo $query.'<br />';
mysql_query($query) or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)
我明白了
UPDATE `masterapp_users` SET `login` = "asdasdasd", `pass` = "a3dcb4d229de6fde0db5686dee47145d", `email` = "asdasdasd", `firstname`
= "asdasdasd", `secondname` = "asdasdasd" WHERE `login` = "88888881"<br />Unknown column 'login' in 'where clause'
Run Code Online (Sandbox Code Playgroud)
但它改变了记录!也许有人能看到我看不到的东西?
哦! 忘了说:如果我将该字符串从浏览器粘贴到PMA,它可以正常工作.
更新:
CREATE TABLE IF NOT EXISTS `masterapp_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(64) COLLATE …Run Code Online (Sandbox Code Playgroud) 在我的脚本中,我使用 cURL 发送数据,并启用 CURLOPT_RETURNTRANSFER。响应是 json 编码的数据。当我尝试 json_decode 时,它返回 null。然后我发现响应在字符串的开头包含 utf-8 BOM 符号 ()。
有一些实验:
$data = $data = curl_exec($ch);
echo $data;
Run Code Online (Sandbox Code Playgroud)
结果是 {"field_1":"text_1","field_2":"text_2","field_3":"text_3"}
$data = $data = curl_exec($ch);
echo mb_detect_encoding($data);
Run Code Online (Sandbox Code Playgroud)
结果 - UTF-8
$data = $data = curl_exec($ch);
echo mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));
// identical to echo mb_convert_encoding($data, 'UTF-8', 'UTF-8');
Run Code Online (Sandbox Code Playgroud)
结果 - {"field_1":"text_1","field_2":"text_2","field_3":"text_3"}
有帮助的一件事是删除前 3 个符号:
if (substr($data, 0, 3) == pack('CCC', 239, 187, 191)) {
$data = substr($data, 3);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果还有另一个 BOM 呢?所以问题是:如何检测 cURL 响应的正确编码?或者如何检测 BOM 已到?或者也许如何使用 BOM 转换响应?