我有5个不同的UIImageViews,命名为Obstacle 1到5.我制作了一个UIImageView数组,因此我很容易一次存储和访问它们,因为我很少只能一次访问一个。我试图改变图像的坐标,坐标也在变化,我已经测试了这一点以确保。我的问题是,当坐标发生变化时,图像不会从原始位置移动。
>>> import os
>>> os.environ['TDSDUMP'] = 'stdout'
>>> import pymssql
>>> conn = pymssql.connect(server='xxx.database.windows.net',
... user='xxx@xxx',
... password='xxxx',
... database='xxx',
... tds_version='8.0',
... )
log.c:167:Starting log file for FreeTDS 0.95
on 2016-08-27 20:47:18 with debug flags 0x4fff.
dblib.c:1160:tdsdbopen(0x15d1070, xxx.database.windows.net:1433, [microsoft])
dblib.c:1186:tdsdbopen: dbproc->dbopts = 0x15fa760
dblib.c:1193:tdsdbopen: tds_set_server(0x14eacf0, "xxx.database.windows.net:1433")
dblib.c:258:dblib_get_tds_ctx(void)
dblib.c:1210:tdsdbopen: About to call tds_read_config_info...
config.c:168:Getting connection information for [xxx.database.windows.net:1433].
config.c:172:Attempting to read conf files.
config.c:353:... $FREETDSCONF not set. Trying $FREETDS/etc.
config.c:366:... $FREETDS not set. Trying $HOME.
config.c:296:Found conf file '/root/.freetds.conf' (.freetds.conf).
config.c:495:Looking for section global.
config.c:554: Found section egserver50.
config.c:554: Found section xxx.database.windows.net.
config.c:568: Reached EOF
config.c:495:Looking for section xxx.database.windows.net:1433.
config.c:554: Found section egserver50.
config.c:554: Found section xxx.database.windows.net.
config.c:568: Reached EOF
config.c:302:[xxx.database.windows.net:1433] not found.
config.c:296:Found conf file '/etc/freetds/freetds.conf' (default).
config.c:495:Looking for section global.
config.c:554: Found section global.
config.c:557:Got a match.
config.c:580: text size = '64512'
config.c:554: Found section egserver50.
config.c:554: Found section egserver70.
config.c:568: Reached EOF
config.c:495:Looking for section xxx.database.windows.net:1433.
config.c:554: Found section global.
config.c:554: Found section egserver50.
config.c:554: Found section egserver70.
config.c:568: Reached EOF
config.c:302:[xxx.database.windows.net:1433] not found.
config.c:353:... $FREETDSCONF not set. Trying $FREETDS/etc.
config.c:366:... $FREETDS not set. Trying $HOME.
config.c:296:Found conf file '/root/.freetds.conf' (.freetds.conf).
config.c:495:Looking for section global.
config.c:554: Found section egserver50.
config.c:554: Found section xxx.database.windows.net.
config.c:568: Reached EOF
config.c:495:Looking for section xxx.database.windows.net.
config.c:554: Found section egserver50.
config.c:554: Found section xxx.database.windows.net.
config.c:557:Got a match.
config.c:580: host = 'xxx.database.windows.net'
config.c:617:Found host entry xxx.database.windows.net
config.c:620:IP addr is 191.238.6.43.
config.c:580: port = '1433'
config.c:580: tds version = '8.0'
config.c:886:Setting tds version to 8.0 (0x701).
config.c:568: Reached EOF
config.c:300:Success: [xxx.database.windows.net] defined in /root/.freetds.conf.
config.c:765:Setting 'dump_file' to 'stdout' from $TDSDUMP.
config.c:689:tds_config_login: client_charset is UTF-8.
config.c:696:tds_config_login: database_name is xxx.
config.c:765:Setting 'dump_file' to 'stdout' from $TDSDUMP.
dblib.c:1237:tdsdbopen: Calling tds_connect_and_login(0x15fae30, 0x15fb4f0)
iconv.c:328:tds_iconv_open(0x15fae30, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:346:setting up conversions for client charset "UTF-8"
iconv.c:348:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:395:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:400:tds_iconv_open: done
net.c:202:Connecting to xxx.xxx.xxx.xxx port 1433 (TDS version 7.1)
net.c:275:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:314:tds_open_socket() succeeded
packet.c:740:Sending packet
0000 12 01 00 34 00 00 00 00-00 00 15 00 06 01 00 1b |...4.... ........|
0010 00 01 02 00 1c 00 0c 03-00 28 00 04 ff 08 00 01 |........ .(......|
0020 55 00 00 02 4d 53 53 51-4c 53 65 72 76 65 72 00 |U...MSSQ LServer.|
0030 08 4d 00 00 - |.M..|
packet.c:639:Received packet
0000 04 01 00 25 00 00 01 00-00 00 15 00 06 01 00 1b |...%.... ........|
0010 00 01 02 00 1c 00 01 03-00 1d 00 00 ff 0c 00 03 |........ ........|
0020 2b 00 00 03 00 - |+....|
login.c:1106:detected flag 3
login.c:472:login packet rejected
query.c:3772:tds_disconnect()
util.c:165:Changed query state from IDLE to DEAD
util.c:322:tdserror(0x14aafa0, 0x15fae30, 20002, 0)
dblib.c:7925:dbperror(0x15fa390, 20002, 0)
dblib.c:7993:dbperror: Calling dblib_err_handler with msgno = 20002; msg->msgtext = "Adaptive Server connection failed (xxx.database.windows.net:1433)"
dblib.c:8015:dbperror: dblib_err_handler for msgno = 20002; msg->msgtext = "Adaptive Server connection failed (xxx.database.windows.net:1433)" -- returns 2 (INT_CANCEL)
util.c:352:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1241:tdsdbopen: tds_connect_and_login failed for "xxx.database.windows.net:1433"!
dblib.c:1463:dbclose(0x15fa390)
dblib.c:243:dblib_del_connection(0x7f7f78fbd980, 0x15fae30)
mem.c:648:tds_free_all_results()
dblib.c:290:dblib_release_tds_ctx(1)
dblib.c:5873:dbfreebuf(0x15fa390)
dblib.c:743:dbloginfree(0x15d1070)
Traceback (most recent call last):
File "pymssql.pyx", line 635, in pymssql.connect (pymssql.c:10734)
File "_mssql.pyx", line 1902, in _mssql.connect (_mssql.c:21821)
File "_mssql.pyx", line 637, in _mssql.MSSQLConnection.__init__ (_mssql.c:6581)
File "_mssql.pyx", line 1630, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:17524)
_mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (ea1eg7cgdn.database.windows.net:1433)\n')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (xxxx.database.windows.net:1433)\n')
我使用这个^来改变图像的位置。在我尝试将图像放入数组之前,这一切都正常。此外,
Obstacles[i].center = CGPointMake(tempNum+(i*125), RandomPosition);
也不再适用。
更新: 声明
Obstacles[i].hidden = YES; Obstacles[i].hidden = NO;
添加到数组
UIImageView *Obstacles[5];
IBOutlet UIImageView *Obstacle1;
IBOutlet UIImageView *Obstacle2;
IBOutlet UIImageView *Obstacle3;
IBOutlet UIImageView *Obstacle4;
IBOutlet UIImageView *Obstacle5;
答案 0 :(得分:0)
您已经像这样创建了数组
UIImageView *Obstacles[5];
而是使用NSMutableArray
NSMutableArray *Obstacles = [[NSMutableArray alloc] init];
在for循环中
for (int i=0;i<5;i++)
{
[Obstacles addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"Obstacle%i", i+1]]]];
}
答案 1 :(得分:0)
您添加到数组代码没有意义。你没有添加你的Obstacles UIImageView,而是创建新的。尝试像这样初始化你的数组:
.GlobalEnv[[paste0("x_",1)]][[1]] <- 6
如果所有这五个UIImageViews在InterfaceBuilder中正确链接,那么改变它的位置就像
UIImageView *Obstacles[5] = {Obstacle1, Obstacle2, Obstacle3, Obstacle4, Obstacle5};
应该有用。
但如果您仍然拥有这个名称索引变量,那么拥有数组会有一些帮助。
如果您有一系列视图,那么您可能不再使用Interface Builder了。尝试在代码中创建它们,手动将它们添加到superview:
Obstacles[i].center = CGPointMake(tempNum+(i*125), RandomPosition);