iPhone - 在Facebook登录后,UISwitch的状态未设置为“On” - (void)fbDidLogin方法(iPhone - After facebook login, status of UISwitch is not setting to 'On' in -(void)fbDidLogin method)
我实施了Facebook登录并检查我的访问令牌的状态
-(void)fbDidLogin
现在,我有一个
UITableView
,其中有一个切换Button
作为UISwitch
,如果我有访问令牌,它将打开。 问题是,当我获得访问令牌时-(void)fbDidLogin
方法被调用。 在这里,我通过调用来设置切换按钮的开关
[self.switch setOn:YES animated:YES];
但没有发生。 当我返回并再次打开该页面时,它显示正确的状态,但不是当我将其设置在
fbDidLogin
。 任何猜测为什么会发生这种情况?对于Facebook身份验证,它会在应用程序之外返回,也许这就是为什么它会发生? 但我打电话来自
fbDidLogin
的WebfbDidLogin
和它的工作正常。代码很简单
- (void)fbDidLogin { [self.switch setOn:YES animated:YES]; }
I have implemented Facebook login and checking the status of my access token in
-(void)fbDidLogin
Now, I have a
UITableView
where I have a toggleButton
asUISwitch
which turns on if I have got an access token. The problem is, when I get an access token-(void)fbDidLogin
method gets called. Here, I'm setting the switch of toggle button on by calling
[self.switch setOn:YES animated:YES];
but its not happening. when I go back and open that page again, its showing the right status but not when I set it in
fbDidLogin
. Any guesses why this is happening?For facebook authentication, it goes outside of the application and comes back, maybe thats why its happening? but I'm calling a webservice from
fbDidLogin
and its working fine.code is simple
- (void)fbDidLogin { [self.switch setOn:YES animated:YES]; }
原文:https://stackoverflow.com/questions/10684330
最满意答案
这是更短,100倍以上的可读性。
编辑 Wug编辑了MarkJ的原始答案中的代码,代码如下:
If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf (lastSelected Is Nothing) Then Set lastSelected = item ' we got our first go ElseIf (item = lastSelected) Then Exit Sub ' we already had what we got End If Set lastSelected = item ' we got something new
这里是MarkJ的回复。 一个嵌套,如果只有一个Set。 看起来很整洁。
If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf Not (lastSelected Is Nothing) Then ' not our first go If (item = lastSelected) Then Exit Sub ' we already had what we got End If End If Set lastSelected = item ' we got something new ' does stuff here? @Wug is that true?
- 要比较VB6中的引用相等性,使用项目是LastSelected。 因为item = lastSelected可能会评估对象中的默认属性,并对它们进行比较!
- 由于简洁似乎是一个目标,请考虑这一点。 如果您在条件X为True时退出Sub,则不需要稍后再检查X. 这是假的! 除非它在评估之间改变它的值(例如X是一个检查系统时钟的函数)。 您正在检查项目是否是lastSelected,然后是否不是。 如果项目没有什么是假的,不要麻烦检查项目是不是什么是真的!
- VB6不会与古代版本的Basic向后兼容
- 不要担心VB6不是其他语言,而放松!
This is shorter and 100x more readable.
EDIT Wug edited the code in MarkJ's original answer, into this:
If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf (lastSelected Is Nothing) Then Set lastSelected = item ' we got our first go ElseIf (item = lastSelected) Then Exit Sub ' we already had what we got End If Set lastSelected = item ' we got something new
Here's MarkJ's edit in response. One nested if, but only one Set. Seems neater to me.
If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf Not (lastSelected Is Nothing) Then ' not our first go If (item = lastSelected) Then Exit Sub ' we already had what we got End If End If Set lastSelected = item ' we got something new ' does stuff here? @Wug is that true?
- To compare reference equality in VB6 use item Is LastSelected. Because item = lastSelected will probably evaluate the default properties in the objects and compare those instead!
- Since brevity appears to be a goal, consider this. If you Exit Sub when condition X is True, you don't need to check X again later. It is False! Unless it changes its value in between evaluations (e.g. X is a function that checks the system clock). You were checking whether item was lastSelected, then whether it wasn't. And if item Is Nothing is False, do not bother to check whether item Is Not Nothing is True!
- VB6 does not short circuit for backwards compatibility with ancient versions of Basic
- Stop worrying that VB6 is not some other language and relax!
相关问答
更多-
这是更短,100倍以上的可读性。 编辑 Wug编辑了MarkJ的原始答案中的代码,代码如下: If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf (lastSelected Is Nothing) Then Set lastSelected = item ' we got our first go ElseIf (item = lastSelected) Then Exit Sub ' we alread ...
-
VB6代码阅读器[关闭](VB6 code reader [closed])[2022-02-27]
我能够在Notepad ++中使用“在所有打开文件中查找”,它具有VB6的格式化模式。 I was able to get "Find in All Open Files" working in Notepad++, which has a formatting mode for VB6. -
寻找VB6在线帮助(Looking for VB6 online help)[2023-04-06]
难怪你是'AngryHacker'。 我相信那是2001年10月。 No wonder you're the 'AngryHacker'. I believe that was Oct 2001. -
停止使用VB6?(Stop using VB6?)[2022-06-26]
在以前的生活中,我参与了同一类型的项目。 原始应用程序是使用Access编写的框架。 然后出现了VB6,它似乎工作得很好,允许更多的功能,而不必改变Access中最初编写的内容。 来了.Net ...... ...尽管我不喜欢.Net的开发阶段,并且被迫使用互操作性层,但这是必要的。 也就是说,我会尽可能主观地回答这个问题: 如果您知道应用程序要完全转换为.Net,那么尽可能多地使用.Net进行新的开发。 除了关于互操作性的看法(和真理)之外,我没有理由把它推迟 - 例如更多的开销,性能等。 侧栏 - 至少 ... -
如何在VB6中编写回调?(How to write a callback in VB6?)[2020-01-16]
我不确定你到底想做什么。 要反转控制 ,只需在类中创建回调函数。 然后使用类(对象)的实例进行回调。 如果需要在运行时在不同的例程之间切换,请使用实现相同接口的单独类 - 策略模式 。 恕我直言地址太复杂,风险太大,无法以这种方式使用。 只有在需要使用Windows API 注册回调函数 时才应使用AddressOf 。 I'm not sure exactly what you're trying to do. To invert control, just create the callback fun ... -
为VB6桌面应用程序创建.net dll vs vb6 dll的最佳实践?(Best Practice for Creating a .net dll vs vb6 dll for VB6 desktop app?)[2023-11-17]
如果你想要一个独立的表单,那么一个ActiveX EXE就足够了。 独立窗体是可以显示的窗体,调用应用程序将继续运行。 这两者不会阻止对方。 在这种情况下.NET DLL是矫枉过正的。 如果您需要涉及传统多任务的内容,比如获取大量数据并处理它,那么.NET DLL可能是一个更好的解决方案,因为多任务比EXE-> VB6的EXE解决方案更直接。 基于你的另一个问题,我觉得创建一个全局的多用途类,公开方法和参数来调用你的EXE所引用的ActiveX EXE中需要的表单,这将是一条可行的路。 更具体的将帮助我制定 ... -
就我所见,在VB6中没有办法别名。 如果您无法重命名该方法,这里可能是一个选项。制作一个简单包装printCommonString的方法呢? Public Sub pCS(ByRef CommonString() As Byte) printCommonString CommonString End Sub There is no way to alias in VB6 as far as I've ever seen. Here might be an option if you aren't a ...
-
您可以为每一行构建一个字符串,当行字符串完成后,将其写入文件 例如使用帖子中的代码: Dim strLine As String Dim fso As New FileSystemObject Dim fsoStream As TextStream Set fsoStream = fso.CreateTextFile("C:\Users\Users\Desktop\File\Sample.csv", True) 'prepare the first row strLine = "Like This is ...
-
您必须为WPF窗口提供一个COM接口(ActiveX用户控件),以暴露.tlb和.idl文件。 为此,我通常创建一个单独的项目,只关注此接口并引用您的WPF项目。 在那里添加一个或几个可以通过VB6程序实例化的类,并根据需要提供所有的GUID和接口描述。 通过这个项目,可以在项目的构建属性中使用'Register for COM Interop'选项,或者(我的首选项)在项目的构建事件脚本中使用regasm来创建.tlb和.idl。 您部署:您的WPF DLL,.tlb和.idl。 然后从VB6项目中引用此 ...
-
在VB6中写入.exe以创建运行时错误“6”:溢出[关闭](Write .exe in VB6 to Create Run-time error '6': Overflow [closed])[2023-03-04]
怎么样: Dim I As Integer I = 32767 + 1 How about: Dim I As Integer I = 32767 + 1